package com.bcx.crm.java.proxy.jdkProxy;

import com.bcx.crm.java.proxy.staticProxy.IUserDao;
import com.bcx.crm.java.proxy.staticProxy.UserDaoImpl;

/**
 * Created by ys on 2018/1/18.
 */
public class ProxyTest {
    public static void main(String [] strings){
        //目标对象
        IUserDao target =new UserDaoImpl();
        //原始的类型---- com.bcx.crm.java.proxy.staticProxy.UserDaoImpl
        System.out.println(target.getClass());
        //给目标对象,创建代理对象
        IUserDao proxyInstance =(IUserDao) new ProxyFactory(target).getProxyInstance();
        //class com.sun.proxy.$Proxy0 内存中动态生成的代理对象
        System.out.println(proxyInstance.getClass());

        //执行目标方法 【代理对象】
        proxyInstance.save();
    }
}
